﻿using System.Windows;
using System.Windows.Controls;
using PropertyExpression.PresentationCode;
using System.Windows.Data;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for Window4.xaml
    /// </summary>
    public partial class Window4
    {
        public Window4()
        {
            InitializeComponent();

            const string template2 = "Template2";
            const string template3 = "Template3";
            const string template1 = "template1";
            this.Nested(
                new Grid().Resources(
                    new ResourceDictionary
                        {
                            {
                                template1,
                                new TextBox().Text("t1").ToDataTemplate()
                            },
                            {
                                template2,
                                new Grid().RowDefinitions(
                                new RowDefinition().Height_Auto(),
                                new RowDefinition().Height_Auto()).Nested(
                                new TextBlock().Text("template2"),
                                new ContentPresenter().Grid_Row(1).Content(new Binding()).ContentTemplate(new Resource(template1))
                                ).ToDataTemplate()
                            },
                            {
                                template3,
                                new Grid().RowDefinitions(
                                new RowDefinition().Height_Auto(),
                                new RowDefinition().Height_Auto()).Nested(
                                new TextBlock().Text("template3"),
                                new ContentPresenter().Grid_Row(1).Content(new Binding()).ContentTemplate(new Resource(template2))
                                ).ToDataTemplate()
                            }
                        }).Nested(
                    new ContentPresenter().ContentTemplate(new Resource(template3))
                    )
                );
        }
    }
}
